import {
  Entity,
  PrimaryGeneratedColumn,
  Column, ManyToOne,
  JoinColumn } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";
import { NpcClusterEntity } from "./npc-cluster.entity";

/**
 * NPC详情表
 * 存储NPC集群下的具体NPC信息
 */
@Entity("npc_details")
@ManualTimestamp()
export class NpcDetailEntity {
  @PrimaryGeneratedColumn({ comment: "NPC详情ID" })
  id!: number;

  @Column("int", { name: "cluster_id", comment: "所属集群ID" })
  clusterId!: number;

  @Column("varchar", { length: 100, comment: "NPC名称" })
  name!: string;

  @Column("varchar", { length: 200, comment: "NPC描述" })
  description!: string;

  @Column("varchar", { length: 100, comment: "NPC图片" })
  image!: string;

  @Column("int", { comment: "NPC等级" })
  level!: number;

  @Column("int", { comment: "NPC数量" })
  count!: number;

  @Column("int", { name: "attack_power", comment: "攻击力", default: 0 })
  attackPower!: number;

  @Column("int", { comment: "防御力", default: 0 })
  defense!: number;

  @Column("int", { comment: "生命值", default: 100 })
  health!: number;

  @Column("int", { name: "exp_reward", comment: "经验值奖励", default: 0 })
  expReward!: number;

  @Column("int", { name: "silver_reward", comment: "银两奖励", default: 0 })
  silverReward!: number;

  @Column("varchar", {
    name: "drop_items",
    length: 500,
    comment: "掉落物品列表(JSON格式)",
    nullable: true })
  dropItems!: string;

  @Column("tinyint", { name: "is_active", comment: "是否激活 (1:激活, 0:禁用)", default: 1 })
  isActive!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", { name: "updated_at", comment: "更新时间", nullable: true })
  updated_at!: Date | null;

  // 关联关系
  @ManyToOne(() => NpcClusterEntity)
  @JoinColumn({ name: "cluster_id" })
  cluster!: NpcClusterEntity;
}
